var stream;

// 获取麦克风和摄像头
// navigator.getUserMedia(
//   {
//     video: true,
//     audio: true
//   },
//   function (s) {
//     console.log("onsuccess", s);
//     stream = s;
//     var video = document.getElementById("video");
//     //inserting our stream to the video tag
//     //video.src = window.URL.createObjectURL(stream);
//     video.srcObject = s;
//   },
//   function (err) {
//     console.log("onerror", err);
//   }
// );
navigator.getUserMedia({
  audio: {
    mandatory: {
      chromeMediaSource: "desktop"
    }
  }, //梓Miao出没 a|z|m|i|a|o|.c-o-m
  video: {
    mandatory: {
      chromeMediaSource: "desktop",
      chromeMediaSourceId: "",
      minWidth: 640,
      maxWidth: 1920,
      minHeight: 360,
      maxHeight: 1080
    }
  }
});

btnGetAudioTracks.addEventListener("click", function () {
  console.log("getAudioTracks");
  console.log(stream.getAudioTracks());
});

btnGetTrackById.addEventListener("click", function () {
  console.log("getTrackById");
  console.log(stream.getTrackById(stream.getAudioTracks()[0].id));
});

btnGetTracks.addEventListener("click", function () {
  console.log("getTracks()");
  console.log(stream.getTracks());
});

btnGetVideoTracks.addEventListener("click", function () {
  console.log("getVideoTracks()");
  console.log(stream.getVideoTracks());
});

btnRemoveAudioTrack.addEventListener("click", function () {
  console.log("removeAudioTrack()");
  stream.removeTrack(stream.getAudioTracks()[0]);
});

btnRemoveVideoTrack.addEventListener("click", function () {
  console.log("removeVideoTrack()");
  stream.removeTrack(stream.getVideoTracks()[0]);
});
